/**
 * 添加或者修改页面
 */
layui.use(['form', 'admin', 'ax', 'upload'], function () {
    var $ = layui.jquery;
    var $ax = layui.ax;
    var upload = layui.upload;
    var form = layui.form;
    var admin = layui.admin;

    //动态班级数据
    $.ajax({
        url: Feng.ctxPath +'/fileTag/getClasslist' ,
        type: 'get',
        dataType: 'json',
        success: function (res) {
            var roleList = res.records;
            console.log(roleList)
            //遍历所有的拿到的复选框数据
            for (i = 0; i < roleList.length; i++) {
                //如果有就渲染选中的模板
                $("#category").append("<option value="+roleList[i].id+">"+roleList[i].tagName+"</option>");
            }
            form.render();
        },
        error: function (e) {
            layer.msg('连接超时，请稍后再试');
        }
    });

    var tagStr = '';
    //表单提交事件
    form.on('submit(btnSubmit)',function (data) {
        var category = $('select[name="category"] option:selected').val();
        console.log(category);
        data.field.clbumId=category;
        var ajax = new $ax(Feng.ctxPath + "/stuManage/addItem", function (data) {
            Feng.success("添加成功！");
            //传给上个页面，刷新table用
            admin.putTempData('formOk', true);
            //关掉对话框
            admin.closeThisDialog();

        }, function (data) {
            Feng.error("添加失败！" + data.responseJSON.message)
        });
        ajax.set(data.field);
        ajax.start();

        return false;
    });
});